<template>
  <el-date-picker
    :disabled="!self.obj.name"
    v-model="value1"
    :style="{width:width}"
    :type="datetype"
    :placeholder="placeholder"
    :value-format="valueFormat"
    :format="format"
    @change="change"
  ></el-date-picker>
</template>
<script>
export default {
  name: "DataPicker",
  data() {
    return {
      value1: null
    };
  },
  watch:{
    value(newValue){
      this.value1 = newValue
      this.self.obj.value = newValue;
    },
    datetype(newValue){
      console.log(newValue,'newValue')
    }
  },
  props: {
    format: {
      type: String,
      default: "yyyy-MM-dd HH:mm:ss"
    },
    datetype: {
      type: String,
      default: "date"
    },
    placeholder: {
      type: String,
      default: "请选择日期时间"
    },
    value: {
      type: [String, Date, Array],
      default: ""
    },
    valueFormat: {
      type: String,
      default: ""
    },
    width: {
      type: String,
      default: "300px"
    },
    self: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  methods: {
    change(val) {
      if (!this.self.obj.name) {
        return false;
      }
      this.self.obj.value = val;
    }
  }
};
</script>
<style>
</style>
